package com.controller.medical;

import com.comm.R;
import com.comm.vo.SupperlierVo;
import com.entity.Supplier;
import com.service.medical.SupplierService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/medicine/supplier")
@Api(value = "药品进销存模块",tags = "供应商维护的所有接口API")
@ApiResponses({
        @ApiResponse(code=200,message="请求成功"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=405,message="请求方法错误"),
        @ApiResponse(code=500,message="后台服务错误")
})
public class SupplierController {

    @Resource
    SupplierService supplierService;

    //查询供应商信息
    @RequestMapping(value = "/findSupList",method = RequestMethod.GET)
    @ApiOperation(value = "查询供应商信息",notes = "查询供应商信息",httpMethod = "GET", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页的条数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "supName",value = "供应商名称",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "contact",value = "联系人",paramType = "query",dataType = "String",required = false)
    })

    public R findSupList(int currentPage,int pageSize,String supName, String contact) {
        return supplierService.findSupList(currentPage,pageSize,supName,contact);
    }

    //编辑按钮(根据id查询供应商信息)
    @RequestMapping(value = "/findSupById",method = RequestMethod.GET)
    @ApiOperation(value = "根据id查询供应商信息",notes = "根据id查询供应商信息",httpMethod = "GET", response = R.class)
    @ApiImplicitParam(name = "id",value = "供应商id",paramType = "query",dataType = "String",required = true)
    public R findSupById(int id) {
        return supplierService.findSupById(id);
    }

    //增加供应商信息
    @RequestMapping(value = "/addSup",method = RequestMethod.POST)
    @ApiOperation(value = "增加供应商信息",notes = "增加供应商信息",httpMethod = "POST", response = R.class)
    @ResponseBody
    public R addSup(Supplier supplier) {

        return supplierService.addSup(supplier);
    }

    //修改供应商信息
    @RequestMapping(value = "/updateSup",method = RequestMethod.POST)
    @ApiOperation(value = "修改供应商信息",notes = "修改供应商信息",httpMethod = "post", response = R.class)
    @ResponseBody
    public R updateSup(Supplier supplier) {

        return supplierService.updateSup(supplier);
    }


    //删除供应商信息
    @RequestMapping(value = "/deleteSup",method = RequestMethod.POST)
    @ApiOperation(value = "删除供应商信息",notes = "删除供应商信息",httpMethod = "post", response = R.class)
    @ApiImplicitParam(name = "id",value = "供应商id",paramType = "query",dataType = "String",required = false)
    @ResponseBody
    public R deleteSup(int id) {

        return supplierService.deleteSup(id);
    }


}
